import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from '@/store'
import TypeNav from "@/components/TypeNav"
import Swiper from "@/components/Swiper";
import Pagination from "@/components/Pagination"
import VueLazyLoad from 'vue-lazyload'
import loading from "@/assets/images/loading.gif";
import VeeValidate from "vee-validate";
import zh_CN from "vee-validate/dist/locale/zh_CN.js";
import"@/mock"
import { Button,Dialog,Message } from 'element-ui'
Vue.use(Button)
Vue.use(Dialog)
Vue.use(VeeValidate)
//配置中文包(必须等插件使用后才能进行配置)
VeeValidate.Validator.localize("zh_CN", {
  messages: {
    ...zh_CN.messages,
    is: (n) => n + "的值必须和上边的值相等",
  },
  //把表单校验的名字映射成中文
  attributes: {
    phone: "手机号码",
    code: "验证码",
    password: "密码",
    passwordAgain: "重复密码",
  },
});

//给Vee-validata扩展规则
VeeValidate.Validator.extend("isAgree", {
  validate: (value) => {
    //自定义校验规则的回调函数接受当前的表单的值作为参数,如果在我们的规则下通过则返回true,否则返回false
    /* if (value === true) {
      return true;
    } else {
      return false;
    } */
    return value;
  },
  //配置错误提示
  getMessage: (n) => {
    return n + "必须同意";
  },
});
Vue.use(VueLazyLoad,{
  loading
})
Vue.prototype.$message = Message


Vue.config.productionTip = false
Vue.component("TypeNav", TypeNav);
Vue.component("Swiper", Swiper);
Vue.component("Pagination", Pagination);



new Vue({
  render: h => h(App),
  beforeCreate(){
Vue.prototype.$bus =this
  },
  router,
  store
}).$mount('#app')
